//
//  YuButton.m
//  YuBao
//
//  Created by hok on 10/10/15.
//  Copyright © 2015 hok. All rights reserved.
//

#import "YuButton.h"

@implementation YuButton


// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
   /* CGRect bounds = self.bounds;
    
    
    UIRectFill(bounds);
    
    [[UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:8.0] addClip];*/
    

    
   
}

- (void)awakeFromNib
{
    [super awakeFromNib];
    //[self setNeedsDisplay];
 /*   UIRectCorner corners;
    
    corners = UIRectCornerAllCorners;

    
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds
                                                   byRoundingCorners:corners
                                                         cornerRadii:CGSizeMake(8.0, 8.0)];
    
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.frame         = self.bounds;
    maskLayer.path          = maskPath.CGPath;
    self.layer.mask         = maskLayer;*/
    

   // self.titleLabel.text = @"hello";
    [self setup];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setup];
    }
    return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    
    if (self) {
        [self setup];
    }
    return self;
}
-(void)setup
{
    self.layer.cornerRadius = 4.0;
    self.layer.masksToBounds = YES;
    
    //  NSMutableAttributedString *str = [self.titleLabel.attributedText mutableCopy];
    //  [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial" size:5] range:NSMakeRange(0, [str length])];
    
    
    // = [UIFont systemFontOfSize:15];
    self.titleLabel.font = [UIFont fontWithName:FONT_NAME size:18];
    
    [self setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];

    
    CGSize imageSize = CGSizeMake(self.frame.size.width, self.frame.size.height);
    UIGraphicsBeginImageContextWithOptions(imageSize, 0, [UIScreen mainScreen].scale);
    [UIColorFromRGBA(0xb8bab7, 1.0) set];
    UIRectFill(CGRectMake(0, 0, imageSize.width, imageSize.height));
    UIImage *pressedColorImg = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    [self setBackgroundImage:pressedColorImg forState:UIControlStateDisabled];
    
    
}



@end
